package com.tlcb.dcdp.dao.impl;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Component;

import com.tlcb.dcdp.bean.User;
import com.tlcb.dcdp.dao.UserDao;

@Component("userDao")
public class UserDaoImpl implements UserDao
{		
	SqlSessionTemplate sqlSession;
	
	@Resource
	public void setSqlSession(SqlSessionTemplate sqlSession)
	{
		this.sqlSession = sqlSession;
	}
	
	public void addUser(User user)
	{
	    sqlSession.insert("com.tlcb.dcdp.dao.UserDao.addUser",user);
	}

	public boolean checkUser(User user)
	{
		boolean b;
		
		User u = (User)sqlSession.selectOne("com.tlcb.dcdp.dao.UserDao.checkUser", user);
		
		if(u == null)
		{
			b = false;
		}
		else
		{
			b = true;
		}
		
		return b;
		
	}

	public boolean checkUsername(String username)
	{
		return false;
	}

	public User getUserByName(String username)
	{
		User user = (User)sqlSession.selectOne("com.tlcb.dcdp.dao.UserDao.getUserByName", username);
		
		return user;
	}
	
	

}
